from coin.exchange.base.kr_rest.py_product import PyProduct
from coin.exchange.base.kr_rest.product_info import (
    ProductInfo, ProductHolder, ProductInfoConstant)
from coin.exchange.bitmex.kr_rest.constants import pi_file
from coin.exchange.bitmex.kr_rest.futures_product import BitmexFuturesProduct


bitmex_product_info = ProductInfoConstant(pi_file)


def get_holder_from_product(product):
  if isinstance(product, PyProduct):
    assert product.market_name == 'Futures' and product.exchange_name == 'Bitmex'
  else:
    assert isinstance(product, BitmexFuturesProduct)
  product_info = bitmex_product_info.get_product_info(product.relative_norm)
  return ProductHolder(product, product_info)
